﻿using STHPMS1.DAL.D_Core;
using System.Data;
using ServiceStack.OrmLite;
using STHPMS1.ICore.I_Entity.Stmpms1;
using STHPMS1.Common.C_Entity.Stmpms1;
using STHPMS1.ICore.I_DAL.Repository;
using System.Collections.Generic;
using System.Data.SqlClient;

namespace STHPMS1.DAL.D_Repository
{
    public class Df_Main_CostRepository : DalBase, IDf_Main_CostRepository
    {


        /// <summary>
        /// 获取路网的所有决策路段
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="roadnetname">路网名称</param>
        /// <returns></returns>
        public List<T> GetDivi<T>(string roadnetname) where T : class,IDn_Divi_Planning
        {
            IDbConnection conn = Adapter.OpenDbConnection();
            string strsql = "select * from DN_DIVI_RESULT"
                                    + "left join B_INVNTORY on DN_DIVI_RESULT.MAINSEGID=B_INVNTORY.SEGID"
                                    + "where B_INVNTORY.ADMDIV='430000' "
                                    + "and B_INVNTORY.ADMGRD in(15,16)"
                                    + "and B_INVNTORY.PVMTTYPE_DICTID in(21)"
                                    + "and B_INVNTORY.RDCLASS_DICTID in(160)"
                                    + "and B_INVNTORY.MANAUT='aaa'";
            return conn.Select<T>(strsql);
        }


        /// <summary>
        /// 获取路网的所有决策路段
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="roadnetname">路网名称</param>
        /// <returns></returns>
        public List<T> GetDivi<T>(string anniname, string Analy_Year) where T : class,IDn_Divi_Planning
        {
            //IDbConnection conn = Adapter.OpenDbConnection();
            //return conn.Select<T>("select * from DN_DIVI_PLANNING"
            //                        + "left join B_INVNTORY on DN_DIVI_PLANNING.MAINSEGID=B_INVNTORY.SEGID"
            //                        + "where  DN_DIVI_PLANNING.DIVI_TIME='"+Analy_Year+"' "+SqlSerach+"");


            IDbConnection conn = Adapter.OpenDbConnection();
            string strsql = "select * from DN_DIVI_PLANNING where ANNI_NAME='" + anniname + "' AND DIVI_TIME='" + Analy_Year + "'";
            return conn.Select<T>(strsql);
        }
    }
}
